home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / lib / os-probes / 50mounted-tests
Text File  |  2008-08-25  |  1KB  |  50 lines

  1. #!/bin/sh
  2. # Sub-tests that require a mounted partition.
  3. set -e
  4. partition=$1
  5.  
  6. . /usr/share/os-prober/common.sh
  7.  
  8. tmpmnt=/var/lib/os-prober/mount
  9. if [ ! -d $tmpmnt ]; then
  10.     mkdir $tmpmnt
  11. fi
  12.  
  13. for type in $(grep -v nodev /proc/filesystems); do
  14.     # hfsplus filesystems are mountable as hfs. Try hfs last so that we
  15.     # can tell the difference.
  16.     if [ "$type" = hfs ]; then
  17.         delaytypes="${delaytypes:+$delaytypes }$type"
  18.     elif [ "$type" = fuseblk ]; then
  19.         if type ntfs-3g >/dev/null 2>&1; then
  20.             types="${types:+$types }ntfs-3g"
  21.         fi
  22.     else
  23.         types="${types:+$types }$type"
  24.     fi
  25. done
  26.  
  27. for type in $types $delaytypes; do
  28.     if mount -o ro -t $type $partition $tmpmnt 2>/dev/null; then
  29.         debug "mounted as $type filesystem"
  30.         for test in /usr/lib/os-probes/mounted/*; do
  31.             debug "running subtest $test"
  32.             if [ -f $test ] && [ -x $test ]; then
  33.                 if $test $partition $tmpmnt $type; then
  34.                     debug "os found by subtest $test"
  35.                     repeat_umount $tmpmnt
  36.                     rmdir $tmpmnt || true
  37.                     exit 0
  38.                 fi
  39.             fi
  40.         done
  41.         repeat_umount $tmpmnt
  42.         break
  43.     fi
  44. done
  45.  
  46. rmdir $tmpmnt || true
  47.  
  48. # No tests found anything.
  49. exit 1
  50.